package cn.com.smartenergyplatform.account.utils.core.enums;

import lombok.Getter;

/**
 * 枚举定义设备类型
 */
@Getter
public enum DeviceType {
    JSAPI("JSAPI", 0),
    H5("H5", 1),
    NATIVE("NATIVE", 2),
    APP("APP", 3),
    UNKNOWN("UNKNOWN", 4);

    private final String type;
    private final Integer code;

    DeviceType(String type, Integer code) {
        this.type = type;
        this.code = code;
    }

    public static DeviceType getDeviceType(Integer code) {
        for (DeviceType deviceType : DeviceType.values()) {
            if (deviceType.getCode().equals(code)) {
                return deviceType;
            }
        }
        return UNKNOWN;
    }
}